home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.cs.util;
-
- import java.io.IOException;
- import sun.tools.javac.Main;
-
- public class JavaUtils {
- private static boolean debug;
- private static boolean cantLoadCompiler;
-
- public static boolean JDKcompile(String var0, String var1) {
- if (debug) {
- System.err.println("JavaEngine: Compiling " + var0);
- System.err.println("JavaEngine: Classpath is " + var1);
- }
-
- String var2 = debug ? "-g" : "-O";
- if (!cantLoadCompiler) {
- String[] var3 = new String[]{var2, "-classpath", var1, var0};
-
- try {
- return (new Main(System.err, "javac")).compile(var3);
- } catch (Throwable var8) {
- System.err.println("WARNING: Unable to load Java 1.1 compiler.");
- System.err.println("\tSwitching to command-line invocation.");
- cantLoadCompiler = true;
- }
- }
-
- String[] var9 = new String[]{"javac", var2, "-classpath", var1, var0};
-
- try {
- Process var4 = Runtime.getRuntime().exec(var9);
- var4.waitFor();
- if (var4.exitValue() == 0) {
- return false;
- }
-
- return true;
- } catch (IOException var5) {
- System.err.println("ERROR: IO exception during exec(javac).");
- } catch (SecurityException var6) {
- System.err.println("ERROR: Unable to create subprocess to exec(javac).");
- } catch (InterruptedException var7) {
- System.err.println("ERROR: Wait for exec(javac) was interrupted.");
- }
-
- return false;
- }
- }
-